In [3]:
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from pydelft.grd_dep import grd, dep
import re
from PyQt4 import QtGui
import sys
import os
import pandas as pd
% matplotlib inline

Get the coordinates of the ends of each boundary section

Read a .bnd file, return coordinates of the end points. I'm making this so I can apply boundary conditions from a completely different model and grid.


In [2]:
class bndFileDialog(QtGui.QMainWindow):
    def __init__(self):
        super(bndFileDialog, self).__init__()
        fname = []
        self.initUI()
    def initUI(self):
        self.setGeometry(300,300,350,300)
        self.setWindowTitle('Open boundary definition file')
        self.openfileDialog()
    def openfileDialog(self):
        fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file', os.getcwd(), "BNT (*.bnd)")
        self.fname = fname

In [ ]:
class bnd():
    '''Delft3d boundary definition file'''
    def __init__(self, fname=None):
        self.read_bnd(fname)
    def read_bnd(self, fname=None):
        '''Read a Delft3d boundary definition file'''
        if not fname:
            app = QtGui.QApplication(sys.argv)
            filedialog = bndFileDialog()
            fname = filedialog.fname
        else:
            fname = fname
            
        pd.read

In [22]:
fname = r'i:\Japan\Data\Sendai\T3\create_riemann\testing\run7\natori_10_v2.bnd'
column_names = ['name','type','forcing','m1','n1','m2','n2',
                'reflection coefficient','vertical profile',
                'label1','label2']
data = pd.read_csv(fname, delim_whitespace=True,header=None,
                   names = column_names)
data[0:15]


Out[22]:
name type forcing m1 n1 m2 n2 reflection coefficient vertical profile label1 label2
0 North1 R T 231 326 234 326 0 uniform NaN NaN
1 North2 R T 571 326 572 326 0 uniform NaN NaN
2 North3 R T 659 326 663 326 0 uniform NaN NaN
3 North4 R T 687 326 700 326 0 uniform NaN NaN
4 North5 R T 703 326 711 326 0 uniform NaN NaN
5 North6 R T 741 326 753 326 0 uniform NaN NaN
6 North7 Z T 818 326 854 326 100 NaN NaN NaN
7 North8 Z T 855 326 891 326 100 NaN NaN NaN
8 North9 Z T 892 326 928 326 100 NaN NaN NaN
9 North10 Z T 929 326 965 326 100 NaN NaN NaN
10 North11 Z T 966 326 974 326 100 NaN NaN NaN
11 South1 R T 225 1 225 1 0 uniform NaN NaN
12 South2 R T 300 1 300 1 0 uniform NaN NaN
13 South3 R T 449 1 450 1 0 uniform NaN NaN
14 South4 R T 541 1 546 1 0 uniform NaN NaN

15 rows × 11 columns


In [ ]: